
#ifndef _GPGPU_FFT_H_
#define _GPGPU_FFT_H_

#include "amdspl.h"
#include "Program.h"
#include "ProgramManager.h"
#include "BufferManager.h"
#include "ConstBuffer.h"
#include "ProgramInfo.h"
#include "LocalBuffer.h"

#include "FFT_test.h"

using namespace amdspl;
using namespace amdspl::core::cal;

class GPGPU_FFT_Manager {
private:
	unsigned int data_size;
	DataDesc *data_desc;
	unsigned int global_buffer_size;

	DeviceManager *devMgr;
	BufferManager *bufMgr;
	ProgramManager* progMgr;
	Program *prog;
    Buffer* in_Buf;
	Buffer* reading_Buf;
	Buffer* computing_Buf;
    Buffer* input_asm_Buf;
	ConstBuffer* const_Buf;

	void gpgpu_format_data(float *input_data, float *formated_data, int proj);
	void gpgpu_deformat_data(float *formated_data, float *ouput_data, int proj) ;
    void generate_input_asm_table(int size);

public:
	GPGPU_FFT_Manager(DataDesc *dd) {
		this->data_size = dd->projection*dd->height*dd->width;
		this->data_desc = dd;
        input_asm_Buf = NULL;
        reading_Buf = NULL;
        computing_Buf = NULL;
        in_Buf = NULL;
	}
	bool gpgpu_init();
	void gpgpu_init_const();
    void gpgpu_input_assambly(float *input_data);
	void gpgpu_iterative_run(float *input_data, float *ouput_data);
	void gpgpu_synchronized_run(float *input_data, float *ouput_data);
	void gpgpu_synchronized_pinned_run(float *input_data, float *ouput_data);
	void gpgpu_fft_run(float *input_data, float *ouput_data);
	void gpgpu_exit();
};

#endif

